import jwt from 'jsonwebtoken';
import constant from '../common/constant.js'
const whiteUrl = ['/login'];
const auth = async (app) => {
  app.use(async (ctx, next) => {
    await next();
    return;
    const token = ctx.request.header.authorization;
    if (whiteUrl.includes(ctx.url)) {
      await next();
      return;
    }
    try {
      jwt.verify(token, constant.JWT_SECRET, {complete: true}, '');
    } catch (e) {
      return ctx.app.emit('error', e.message, ctx);
    }
    await next();
  })
}
export default auth